package org.eduapp.test.account;


import org.eduapp.trains.ServiceException;
import org.eduapp.trains.model.announce.ModelAnnounce;
import org.eduapp.trains.service.account.AccountService;
import org.eduapp.trains.service.announce.AnnounceService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class testService{
	/*@Test
	public void tesa() throws ServiceException{
		ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{
				"spring/applicationContext-model-account.xml","spring/applicationContext.xml"});
				AccountService g= (AccountService) ctx.getBean("accountService");
				ModelAccount ma=new ModelAccount();
				ma.setAccountPassword("123");
				ma.setAccountClass("22");
				ma.setAccountEmail("23123");
				ma.setAccountIdentification("2222123");
				ma.setAccountMajority("asd");
				ma.setAccountMobilePhone("111");
				ma.setAccountNo("23123");
				ma.setAccountRealName("123123");
				ma.setAccountGrade("22");
				ma.setAccountStatus(1);
				ma.setAccount_role(0);
				ModelRoles ac=new ModelRoles();
				ac.setRole_id("1");
				//System.out.println(ac.getRoleDesc());
				ma.setAccountRole(ac);
				
				//System.out.println(gr.getChgreeting());
				g.saveOrUpdate(ma);
	}
	@Test
	public void testSearch() throws ServiceException{
		ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{
				"spring/applicationContext-model-account.xml","spring/applicationContext.xml"});
				AccountService g= (AccountService) ctx.getBean("accountService");
				ModelAccount ma=new ModelAccount();
				List<ModelAccount>list=g.getByModel(ma);
				int a=g.getByModel(ma).size();
				System.out.println(a);
				/*
				ma.setAccountPassword("123");
				ma.setAccountClass("22");
				ma.setAccountEmail("23123");
				ma.setAccountIdentification("2222123");
				ma.setAccountMajority("asd");
				ma.setAccountMobilePhone("111");
				ma.setAccountNo("23123");
				ma.setAccountRealName("123123");
				ma.setAccountGrade("22");
				ma.setAccountStatus(1);
				ma.setAccount_role(0);
				ModelRoles ac=new ModelRoles();
				ac.setRole_id("1");
				//System.out.println(ac.getRoleDesc());
				ma.setAccountRole(ac);
				
				//System.out.println(gr.getChgreeting());
				g.saveOrUpdate(ma);
				}*/
	
/*
	@Test
	public void testSearch() throws ServiceException{
		ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{
				"spring/applicationContext-model-order.xml","spring/applicationContext.xml","spring/applicationContext-model-account.xml"});
				OrderService g= (OrderService) ctx.getBean("orderService");
				AccountService a=(AccountService) ctx.getBean("accountService");
				ModelAccount ma=new ModelAccount();
				ma.setAccountRealName("zlf");
				List<ModelAccount> list=a.getByModel(ma);
				ModelOrder mo=new ModelOrder();
				//mo.setOrderNo("001");
				//List t=(List) g.get(mo, list, 0, 0, null, null).getItems();
				//int aa=g.get(mo, list, 0, 0, null, null).getItemCount();
				System.out.println();
				
	}*/
	
	@Test
	public void testAdd() throws ServiceException{
		ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{
				"spring/applicationContext-model-announce.xml","spring/applicationContext.xml","spring/applicationContext-model-account.xml"});
				AnnounceService g= (AnnounceService) ctx.getBean("announceService");
				AccountService a=(AccountService) ctx.getBean("accountService");
				ModelAnnounce ma=new ModelAnnounce();
				ma.setAnnounceStatus(1);
				ma.setAnnounceText("123");
				ma.setAnnounceSubject("ssss");
				g.saveOrUpdate(ma);
				
	}
}